/* 
 * BAT_Parser.h
 *
 * Parser for BAT.
 *
 * $Id: BAT_Parser.h 927 2006-09-03 06:17:24Z rpz $
 *
 * Bob Zimmermann <rpz@cse.wustl.edu>
 * Totally free.
 *
 */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include "BAT_Annotation.h"

#ifndef BAT_PARSER_H
#  define BAT_PARSER_H

typedef enum _BAT_Parser_Type
{
  BAT_GTF_Parser_Type,
  BAT_Unknown_Parser_Type
} BAT_Parser_Type;

typedef struct _BAT_Parser BAT_Parser;
typedef struct _BAT_Parse_Plugin BAT_Parse_Plugin;

struct _BAT_Parse_Plugin
{
  BAT_Parser_Type type;
  int (*canparse) (char *name);	/* can you parse the file with name 'name'? */
  void *(*construct) (void);	/* allocate necessary stuff */
  void (*delete) (void *parser, int);	/* remove necessary stuff */
  BAT_Free_Feature **(*parsefile) (void *parser, FILE * fh, unsigned *n_feats);
};

struct _BAT_Parser
{
  darray_t *features;
};

BAT_Parser *BAT_Parser_new ();
void BAT_Parser_delete (BAT_Parser * p, int);
void BAT_Parser_parsefile_by_name (BAT_Parser * p, char *filename);
void BAT_Parser_parsefile_by_fh (BAT_Parser * p, FILE * file,
				 BAT_Parser_Type type);
BAT_Free_Feature **BAT_Parser_claim_features (BAT_Parser * p, unsigned *n_feats);
char *BAT_Parser_get_filename_extension (char *filename);

#endif /* BAT_PARSER_H */
